import 'package:ca_dsp_pro/src/tool/assets.dart';
import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';

class BgChart extends StatefulWidget {
  const BgChart({super.key});

  @override
  State<BgChart> createState() => _BgChartState();
}

class _BgChartState extends State<BgChart> {
  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constrains) {
        ///计算绘图的真实宽度，高度
        var size = Size(constrains.maxWidth, constrains.maxHeight);
        var padding = const EdgeInsets.only(left: 30, right: 10, top: 10, bottom: 15);
        return Container(
            child: SizedBox.expand(
          child: Stack(
            children: [
              Positioned(
                  left: 0,
                  top: 0,
                  bottom: 0,
                  right: 0,
                  child: Container(
                    color: Color_bg_view2,
                  )),
              Obx(() {
                var global = globalController.rxModel.value;
                var sign = global.ch_list[0].sign_list[0];
                return ChartView(
                    label_color: Colors.white,
                    border_color: Colors.white,
                    x_line_color: Colors.white,
                    y_line_color: Colors.white,
                    ch: global.current_ch,
                    size: size,
                    padding: padding,
                    showPoints: true,
                    drawGradient: true,
                    minY: sign.min_gain,
                    maxY: sign.max_gain);
              })
            ],
          ),
        ));
      },
    );
  }
}
